diff --git a/swh/web/ui/templates/upload_and_search.html b/swh/web/ui/templates/upload_and_search.html index 6c9b3a85b..1c90f4b06 100644 --- a/swh/web/ui/templates/upload_and_search.html +++ b/swh/web/ui/templates/upload_and_search.html @@ -1,98 +1,102 @@ {% extends "layout.html" %} {% block title %}Search SWH{% endblock %} {% block content %} <!-- CryptoJS assumed to be installed as a debian package --> <script src="{{ url_for('static', filename='lib/core.js') }}"></script> <script src="{{ url_for('static', filename='lib/lib-typedarrays.js') }}"></script> <script src="{{ url_for('static', filename='lib/sha1.js') }}"></script> <script src="{{ url_for('static', filename='lib/sha256.js') }}"></script> <script src="{{ url_for('static', filename='js/filedrop.js') }}"></script> <div class="container"> <form id="searchForm" action="{{ url_for('search') }}" class="form" method="post" enctype="multipart/form-data"> <div class="form-group"> <label for="sha1_textinput">Search with SHA-1 or SHA-256:</label> <br/> <div id="textinput" class="input-group"> <input id="sha1_textinput" type="text" class="form-control" name="q" placeholder="SHA-1 or SHA-256 checksum" /> </div> </div> <div id="filesinput" class="input-group"> <label for="fileElem">Search with files</label> <div id="fileinput" class="container text-center" style="border: 1px dashed black"> Drag and drop or click here to hash files and search for them. Your files will NOT be uploaded, hashing is done locally. Filesizes over 20Mb may be slow to process, use with care. <div id="filelist" class="row"> </div> </div> </div> <div class="text-center" style="margin-top: 10px"> <button id="submitall" type="submit" class="btn btn-primary"> <span class="glyphicon glyphicon-search" aria-hidden="true"></span> Search </button> </div> </form> <input type="file" id="fileElem" class="form-control" multiple name="filename" value="" style="display:none" placeholder="File(s) to upload, hash and search for SHA-1 or SHA-256 checksum" /> {% if search_stats is not none and search_stats %} <label id="stats"> Files available in SWH: {{ '%.2f' | format(search_stats['pct']) }}% of {{ search_stats['nbfiles'] }} files. </label> {% endif %} - {% if responses is not none and responses %} + {% if search_res is not none %} <table id="results" class="table table-striped"> <thead class="thead-default"> <th>File name</th> <th>SHA1 checksum</th> <th>Result</th> </thead> - {% for resp in responses %} + {% for res in search_res %} <tr> - <td>{{ resp['filename'] }}</td> - {% if resp['found'] %} - <td><a href="{{ url_for('browse_content') }}sha1:{{ resp['sha1'] }}">{{ resp['sha1'] }}</a></td> + {% if res['filename'] is not none %} + <td>{{ res['filename'] }}</td> + {% else %} + <td>From text input</td> + {% endif %} + {% if res['found'] %} + <td><a href="{{ url_for('browse_content') }}sha1:{{ res['sha1'] }}">{{ res['sha1'] }}</a></td> <td><span class="glyphicon glyphicon-ok file-found"></span></td> {% else %} - <td>{{ resp['sha1'] }}</td> + <td>{{ res['sha1'] }}</td> <td><span class="glyphicon glyphicon-remove file-notfound"></span></td> {% endif %} </tr> {% endfor %} </table> {% endif %} {% if messages is not none and messages %} <div id="messages" class="row"> {% for message in messages %} <br /> <div class="span8">{{ message | safe }}</div> {% endfor %} </div> {% endif %} <!-- jQuery setup --> <div id="test"></div> <script> // Delegate dropbox click $("#fileinput").inputclick($("#fileElem")); // Make the dropbox available for drag & drop $("#fileElem").filedialog($("#filelist"), $("#searchForm")); - $("#fileinput").filedrop($("#filelist"), $("#searchForm")); // Make the submission button receptive to files + $("#fileinput").filedrop($("#filelist"), $("#searchForm")); </script> </div> {% endblock %}